package com.mz.ozy.mvp.presenter;


import android.app.Activity;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.VipUpBean;
import com.mz.ozy.mvp.model.MeModel;
import com.mz.ozy.mvp.view.VipUpContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class VipUpPresenter extends BasePresenterImpl<VipUpContract.View> implements VipUpContract.Presenter {

    private MeModel mModel;


    public VipUpPresenter() {
        mModel = new MeModel();
    }

    @Override
    public void getVipInfo(Activity activity) {
        mModel.getVipUpInfo(activity)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<VipUpBean>(mView) {
                    @Override
                    public void onSuccesss(VipUpBean bean) {
                        mView.getVipInfoSuccess(bean);
                    }
                });
    }


    @Override
    public void onVipPay(Activity activity, String id, String payType) {
        mModel.onVipPay(activity, id, payType)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {
                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.onVipPaySuccess(bean);
                    }
                });
    }
}
